package com.bum.sock.poll.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;

import com.bum.sock.poll.bo.IdBO;
import com.bum.sock.poll.bo.Loader;

public class IdServlet extends HttpServlet {
	private static final long	serialVersionUID	= 1L;

	IdBO						idBO				= Loader.getBean("idBO");

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String callback = request.getParameter("callback");
		if (StringUtils.isNotBlank(callback)) {
			response.setContentType("application/json");
			PrintWriter out = response.getWriter();
			String json = idBO.getId(callback, request.getSession(true).getId());
			out.print(json);
		}
	}
}
